package com.rmb.userinfo.service.impl;

import com.rmb.userinfo.dao.InvoiceInformationDao;
import com.rmb.mart.entity.invoice.InvoiceInformation;
import com.rmb.userinfo.service.InvoiceInformationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (InvoiceInformation)表服务实现类
 *
 * @author makejava
 * @since 2021-01-20 11:03:15
 */
@Service("invoiceInformationService")
public class InvoiceInformationServiceImpl implements InvoiceInformationService {
    @Resource
    private InvoiceInformationDao invoiceInformationDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public InvoiceInformation queryById(Long id) {
        return this.invoiceInformationDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<InvoiceInformation> queryAllByLimit(int offset, int limit) {
        return this.invoiceInformationDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param invoiceInformation 实例对象
     * @return 实例对象
     */
    @Override
    public InvoiceInformation insert(InvoiceInformation invoiceInformation) {
        this.invoiceInformationDao.insert(invoiceInformation);
        return invoiceInformation;
    }

    /**
     * 修改数据
     *
     * @param invoiceInformation 实例对象
     * @return 实例对象
     */
    @Override
    public InvoiceInformation update(InvoiceInformation invoiceInformation) {
        this.invoiceInformationDao.update(invoiceInformation);
        return this.queryById(invoiceInformation.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.invoiceInformationDao.deleteById(id) > 0;
    }

    /**
     * 查询所有信息
     * @return
     */
    @Override
    public List<InvoiceInformation> selectAll() {
        return invoiceInformationDao.selectAll();
    }
}